const { log } = require("console");
const fs = require("fs")
const path = require('path')
const filePath = path.join(__dirname, 'data.txt')
var all = fs.readFileSync(filePath, "utf-8")
//获取全部数据
const getshangData = () => {
    try {
        all = all.toString()
        return JSON.parse(all)
    } catch (e) {
        if (e.errno === -4058) {
            fs.writeFileSync(filePath, '{}')
            return {}
        }
    }
}
//写入

module.exports = {
    getshangData
}